package com.zh.juc.thread;

import java.util.concurrent.TimeUnit;

/**
 * @Author: zhanghuan
 * @date: 2022/10/6 13:42
 * @description: create it
 */
public class DaemoDemo {
    public static void main(String[] args) {
        // boolean daemon = Thread.currentThread().isDaemon();
        // System.out.println(daemon);

        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "\t 开始运行" +
                    (Thread.currentThread().isDaemon() ? "守护线程" : "用户线程"));
        }, "t1");
        t1.setDaemon(true);
        t1.start();

        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "\t 主线程");

    }
}